#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'
int a[20], book[20], n = 9;

void dfs(int k) {
    if (k >= n) {
        //a[0..2]=x a[3..5]=y a[6..8]=z
        int x = a[0] * 100 + a[1] * 10 + a[2];
        int y = a[3] * 100 + a[4] * 10 + a[5];
        int z = a[6] * 100 + a[7] * 10 + a[8];

        if (y == 2 * x && z == 3 * x) {
            cout << x << " " << y << " " << z << endl;
        }
        return;
    }
    for (int i = 0; i < n; i++) {
        if (book[i] == 1)continue;//查表
        a[k] = i + 1;
        book[i] = 1;//写入标记数组
        dfs(k + 1);
        book[i] = 0;//当我们访问完叶子结点后，必须要重置book[i]为未选择状态
    }


}


int main() {
    dfs(0);

    return 0;
}
